package com.firefly.dao.assembler.mc;

import com.firefly.dao.dao.mc.po.UserPo;
import com.firefly.dao.vo.mc.McUserVo;
import com.firefly.util.utils.FuncUtils;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @description:
 * @author: lzg(萤火科技 ： 854378082 @ qq.com)
 * @date: 2023/2/10
 **/
@Component
public class McUserAssembler {
    public McUserVo getVo(UserPo entity){
        McUserVo detail = new McUserVo();
        detail.setId(entity.getId());
        detail.setLevelId(entity.getLevelId());
        detail.setPhone(entity.getPhone());
        detail.setOpenid(entity.getOpenid());
        detail.setNickname(entity.getNickname());
        detail.setThumb(entity.getThumb());
        detail.setSex(entity.getSex());
        detail.setBirthday(entity.getBirthday());
        detail.setMoney(entity.getMoney());
        detail.setLevel1(entity.getLevel1());
        detail.setLevel2(entity.getLevel2());
        detail.setSharecode(entity.getSharecode());
        detail.setDelFlag(entity.getDelFlag());
        return detail;
    }
    public UserPo getPo(String phone,String openId){
        UserPo entity = new UserPo();
        entity.setLevelId(1);
        entity.setPhone(phone);
        entity.setOpenid(openId);
        Map passwdMap = FuncUtils.getPassword("123456",8);
        entity.setCrypt((String) passwdMap.get("crypt"));
        entity.setPassword((String) passwdMap.get("pwd"));
        entity.setSharecode(FuncUtils.getUUIDString());
        return entity;
    }
}
